{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "requested-force",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\u001b[36mingredient\u001b[39m: (\u001b[32mString\u001b[39m, \u001b[32mInt\u001b[39m) = (\u001b[32m\"sugar\"\u001b[39m, \u001b[32m25\u001b[39m)"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "val ingredient = (\"sugar\",25):Tuple2[String,Int]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "racial-prototype",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "25\n"
     ]
    }
   ],
   "source": [
    "println(ingredient._2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "charged-recall",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "sugar\n",
      "25\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\u001b[36mname\u001b[39m: \u001b[32mString\u001b[39m = \u001b[32m\"sugar\"\u001b[39m\r\n",
       "\u001b[36mquantity\u001b[39m: \u001b[32mInt\u001b[39m = \u001b[32m25\u001b[39m"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "val (name, quantity) = ingredient\n",
    "\n",
    "println(name) // Sugar\n",
    "\n",
    "println(quantity) // 25"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "personalized-mayor",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\u001b[36mplantets\u001b[39m: \u001b[32mList\u001b[39m[(\u001b[32mString\u001b[39m, \u001b[32mDouble\u001b[39m)] = \u001b[33mList\u001b[39m(\n",
       "  (\u001b[32m\"M\"\u001b[39m, \u001b[32m59.9\u001b[39m),\n",
       "  (\u001b[32m\"V\"\u001b[39m, \u001b[32m108.3\u001b[39m),\n",
       "  (\u001b[32m\"E\"\u001b[39m, \u001b[32m149.6\u001b[39m),\n",
       "  (\u001b[32m\"Mars\"\u001b[39m, \u001b[32m227.9\u001b[39m)\n",
       ")"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "val plantets = List((\"M\",59.9),(\"V\",108.3),(\"E\",149.6),(\"Mars\",227.9))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "prescription-watershed",
   "metadata": {},
   "outputs": [],
   "source": [
    "plantets.foreach{\n",
    "    case (\"Ee\", distance) =>\n",
    "    println(s\"Our planet is $distance million kilometers from the sun\")\n",
    "    case _ =>\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "asian-cooper",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\u001b[36mnumpairs\u001b[39m: \u001b[32mList\u001b[39m[(\u001b[32mInt\u001b[39m, \u001b[32mInt\u001b[39m)] = \u001b[33mList\u001b[39m((\u001b[32m1\u001b[39m, \u001b[32m2\u001b[39m), (\u001b[32m2\u001b[39m, \u001b[32m3\u001b[39m))"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "val numpairs = List((1,2),(2,3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "bronze-freedom",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n",
      "6\n"
     ]
    }
   ],
   "source": [
    "numpairs.foreach{case (a,b) => println(a*b)}\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "turkish-wisconsin",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n",
      "-21\n",
      "1120\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "\u001b[36mnumPairs\u001b[39m: \u001b[32mList\u001b[39m[(\u001b[32mInt\u001b[39m, \u001b[32mInt\u001b[39m)] = \u001b[33mList\u001b[39m((\u001b[32m2\u001b[39m, \u001b[32m5\u001b[39m), (\u001b[32m3\u001b[39m, \u001b[32m-7\u001b[39m), (\u001b[32m20\u001b[39m, \u001b[32m56\u001b[39m))"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "val numPairs = List((2, 5), (3, -7), (20, 56))\n",
    "\n",
    "for ((a, b) <- numPairs) {\n",
    "\n",
    "  println(a * b)\n",
    "  \n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "developing-testament",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Scala",
   "language": "scala",
   "name": "scala"
  },
  "language_info": {
   "codemirror_mode": "text/x-scala",
   "file_extension": ".scala",
   "mimetype": "text/x-scala",
   "name": "scala",
   "nbconvert_exporter": "script",
   "version": "2.11.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
